#!/bin/bash

chown $_INIT_UID:$_INIT_GID $_INIT_WORKDIR
chown $_INIT_UID:$_INIT_GID ${_INIT_WORKDIR%/*}
if [ "$_INIT_USER" != "$_INIT_GROUP" -o $_INIT_UID != $_INIT_GID ]; then
	groupadd $_INIT_GROUP -g $_INIT_GID
	useradd -m -s /bin/bash $_INIT_USER -u $_INIT_UID -g $_INIT_GID
else
	useradd -m -s /bin/bash $_INIT_USER -u $_INIT_UID
fi
su - $_INIT_USER -c 'cp -a /etc/skel/. $HOME/'
echo "$_INIT_USER:123456" | chpasswd
echo "$_INIT_USER ALL = NOPASSWD: ALL" > /etc/sudoers.d/$_INIT_USER
sed -i -e "s|%USER%|$_INIT_USER|g" /etc/init.d/myvnc
